package com.whfc.ms.api.cfg.service.factory;

import com.alibaba.fastjson.JSON;
import com.whfc.common.exception.BizException;
import com.whfc.common.result.ResultEnum;
import com.whfc.fvs.dto.FvsSettingDTO;
import com.whfc.fvs.service.FvsSettingService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author qzexing
 * @version 1.0
 * @date 2021-07-30 15:41
 */
@Service(ConfigCenterServiceConstant.FVS_SERVICE)
public class ConfigCenterServiceFvsImpl implements ConfigCenterService {

    @DubboReference(interfaceClass = FvsSettingService.class, version = "1.0.0")
    private FvsSettingService fvsSettingService;


    @Override
    public List getConfigList(Integer deptId, String module) {
        return fvsSettingService.getConfigList(deptId);
    }

    @Override
    public void setConfig(Integer deptId, String module, String dataStr) {
        List<FvsSettingDTO> settingList = JSON.parseArray(dataStr, FvsSettingDTO.class);
        if (settingList == null) {
            throw new BizException(ResultEnum.PARAM_ERROR.getCode(), "参数类型错误.");
        }
        fvsSettingService.platformConfigure(deptId, settingList);
    }

}
